package com.naizhuai.ui.mianbusiness.setting;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.naizhuai.R;
import com.naizhuai.ui.BaseActivity;
import com.naizhuai.ui.components.LabelsView;
import com.naizhuai.ui.components.SingleLabelsView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;


/**
 * 排行榜展示的activity
 */
public class RankingListActivity extends BaseActivity implements View.OnClickListener {
    private static final String TAG = "RankingListActivity";
    @BindView(R.id.labels)
    LabelsView labels;
    @BindView(R.id.enable)
    Button enable;
    @BindView(R.id.unable)
    Button unable;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        List<String> labelsData = new ArrayList<>();

        Collections.addAll(labelsData,"测试一","测试二","测试三","测试四","测试五","测试六");

        labels.setHook(false);
        labels.setFork(false);
        labels.setLabels(labelsData, new LabelsView.LabelTextProvider<String>() {
            @Override
            public CharSequence getLabelText(SingleLabelsView label, int position, String data) {
                return data;
            }
        });
        labels.setLabelsViewsEnable(false);
        labels.setChosenLabelViewsEnable(new int[]{0}, true);
        labels.setOnLabelSelectChangeListener(new LabelsView.OnLabelSelectChangeListener() {
            @Override
            public void onLabelSelectChange(SingleLabelsView label, Object data, boolean isSelect, int position) {
                if (position == 3 && labels.nextView(position).isEnabled()) {
                    labels.nextView(position).setTextSelected(false);
                    labels.nextView(position).setText("已经被初始化");
                } else {
                    if (position + 1 < labelsData.size())
                        labels.setChosenLabelViewsEnable(new int[]{position + 1}, true);
                }
            }
        });

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_test_labels_layout;
    }

    @OnClick({R.id.enable, R.id.unable})
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.enable:
                labels.setLabelsViewsEnable(false);
                break;
            case R.id.unable:
                labels.setChosenLabelViewsEnableReversal(new int[]{1, 4});
                break;
        }
    }
}
